{% extends "layout.html" %}

{% block css %}
    <style>

    </style>
{% endblock %}
{% block content %}

    {#表按钮#}
    <div class="btn-group" role="group" aria-label="...">

        <form class="navbar-form navbar-left" method="GET">
            <button type="submit" class="btn btn-primary" aria-label="Left Align" name="table_choice"
                    value="product"><span
                    class="glyphicon glyphicon-th-list" aria-hidden="true"> 商品</span></button>
            <button type="submit" class="btn btn-primary" aria-label="Left Align" name="table_choice"
                    value="sales"><span
                    class="glyphicon glyphicon-th-list" aria-hidden="true"> 销售</span>
            </button>
            <button type="submit" class="btn btn-primary" aria-label="Left Align" name="table_choice"
                    value="category"><span
                    class="glyphicon glyphicon-th-list" aria-hidden="true"> 分类</span>
            </button>
            <button type="submit" class="btn btn-primary" aria-label="Left Align" name="table_choice"
                    value="brand"><span
                    class="glyphicon glyphicon-th-list" aria-hidden="true"> 品牌</span>
            </button>
            <button type="submit" class="btn btn-primary" aria-label="Left Align" name="table_choice"
                    value="store"><span
                    class="glyphicon glyphicon-th-list" aria-hidden="true"> 店铺</span>
            </button>
        </form>

        {#    搜索栏#}
        <form class="navbar-form navbar-left" method="GET">
            {% if table_choice == "product" %}
                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-tags"
                                                                            aria-hidden="true"></span></span>
                    <input type="text" class="form-control" placeholder="商品id" aria-describedby="basic-addon1"
                           name="product_id"
                           value="{{ product_id }}">
                </div>
                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-tags"
                                                                            aria-hidden="true"></span></span>
                    <input type="text" class="form-control" placeholder="商品种类" aria-describedby="basic-addon1"
                           name="category"
                           value="{{ category }}">
                </div>
                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-tags"
                                                                            aria-hidden="true"></span></span>
                    <input type="text" class="form-control" placeholder="商品品牌" aria-describedby="basic-addon1"
                           name="brand" value="{{ brand }}">
                </div>
                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-tags"
                                                                            aria-hidden="true"></span></span>
                    <input type="text" class="form-control" placeholder="商品名称" aria-describedby="basic-addon1"
                           name="name"
                           value="{{ name }}">
                </div>

                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-zoom-in"
                                                                            aria-hidden="true"></span></span>
                    <button type="submit" class="btn btn-default" aria-describedby="basic-addon1">搜索</button>
                </div>

            {% endif %}

        </form>
    </div>


    <table class="table table-bordered">
        <thead>
        <tr>

            {#            <th>商品id</th>#}
            {#            <th>商品分类</th>#}
            {#            <th>商品品牌</th>#}
            {#            <th>商品名称</th>#}
            {#            <th>商品价格</th>#}
            {% if table_choice == 'product' %}
                <th>商品id</th>
                <th>商品名称</th>
                <th>商品价格</th>
                <th>商品分类</th>
                <th>商品销量</th>
                <th>商品品牌</th>
                <th>商品评价</th>
                <th>商品店铺</th>
                <th>操作</th>
            {% elif table_choice == 'sales' %}
                <th>商品id</th>
                <th>商品名称</th>
                <th>销售数量</th>
                <th>商品分类</th>
                <th>商品品牌</th>
                <th>商品评价</th>
                <th>商品店铺</th>
                <th>操作</th>
            {% elif table_choice == 'category' %}
                <th>分类名称</th>
                <th>总销售数量</th>
                <th>商品平均评分</th>
                <th>商品平均价格</th>
                <th>商品平均销量</th>
                <th>商品最高价格</th>
                <th>商品最低价格</th>
                <th>操作</th>
            {% elif table_choice == 'brand' %}
                <th>品牌名称</th>
                <th>总销售数量</th>
                <th>商品平均评分</th>
                <th>商品平均价格</th>
                <th>商品平均销量</th>
                <th>商品最高价格</th>
                <th>商品最低价格</th>
                <th>操作</th>
            {% elif table_choice == 'store' %}
                <th>店铺名</th>
                <th>总销售数量</th>
                <th>商品平均评分</th>
                <th>商品平均价格</th>
                <th>商品平均销量</th>
                <th>商品最高价格</th>
                <th>商品最低价格</th>
                <th>操作</th>
            {% endif %}
        </tr>
        </thead>
        <tbody>
        {% for item in items %}

            <tr>
                {% if table_choice == 'product' %}
                    <th scope="row">{{ item.product_id }}</th>
                    <td>{{ item.product_name }}</td>
                    <td>{{ item.price }}</td>
                    <td>{{ item.category }}</td>
                    <td>{{ item.sales_volume }}</td>
                    <td>{{ item.brand }}</td>
                    <td>{{ item.rating }}</td>
                    <td>{{ item.store }}</td>
                    <td>
                        <a class="btn btn-default"
                           href="/system/data_show/update/{{ table_choice }}/{{ item.product_id }}"
                           role="button">修改</a>
                        <a class="btn btn-default"
                           href="/system/data_show/delete/{{ table_choice }}/{{ item.product_id }}"
                           role="button">删除</a>
                    </td>
                {% elif table_choice == 'sales' %}
                    <td>{{ item.product_id }}</td>
                    <td>{{ item.product_name }}</td>
                    <td>{{ item.sales_volume }}</td>
                    <td>{{ item.category }}</td>
                    <td>{{ item.brand }}</td>
                    <td>{{ item.rating }}</td>
                    <td>{{ item.store }}</td>
                    <td>
                        <a class="btn btn-default"
                           href="/system/data_show/update/{{ table_choice }}/{{ item.product_id }}"
                           role="button">修改</a>
                        <a class="btn btn-default"
                           href="/system/data_show/delete/{{ table_choice }}/{{ item.product_id }}"
                           role="button">删除</a>
                    </td>
                {% elif table_choice == 'category' %}
                    <td>{{ item.category }}</td>
                    <td>{{ item.total_sales_volume }}</td>
                    <td>{{ item.avg_rating }}</td>
                    <td>{{ item.avg_price }}</td>
                    <td>{{ item.avg_sales_volume_per_product }}</td>
                    <td>{{ item.max_price }}</td>
                    <td>{{ item.min_price }}</td>

                    <td>
                        <a class="btn btn-default" href="/system/data_show/update/{{ table_choice }}/{{ item.category }}"
                           role="button">修改</a>
                        <a class="btn btn-default" href="/system/data_show/delete/{{ table_choice }}/{{ item.category }}"
                           role="button">删除</a>
                    </td>
                {% elif table_choice == 'brand' %}
                    <td>{{ item.brand }}</td>
                    <td>{{ item.total_sales_volume }}</td>
                    <td>{{ item.avg_rating }}</td>
                    <td>{{ item.avg_price }}</td>
                    <td>{{ item.avg_sales_volume_per_product }}</td>
                    <td>{{ item.max_price }}</td>
                    <td>{{ item.min_price }}</td>

                    <td>
                        <a class="btn btn-default" href="/system/data_show/update/{{ table_choice }}/{{ item.brand }}"
                           role="button">修改</a>
                        <a class="btn btn-default" href="/system/data_show/delete/{{ table_choice }}/{{ item.brand }}"
                           role="button">删除</a>
                    </td>
                {% elif table_choice == 'store' %}
                    <td>{{ item.store }}</td>
                    <td>{{ item.total_sales_volume }}</td>
                    <td>{{ item.avg_rating }}</td>
                    <td>{{ item.avg_price }}</td>
                    <td>{{ item.avg_sales_volume_per_product }}</td>
                    <td>{{ item.max_price }}</td>
                    <td>{{ item.min_price }}</td>
                    <td>
                        <a class="btn btn-default"
                           href="/system/data_show/update/{{ table_choice }}/{{ item.store }}"
                           role="button">修改</a>
                        <a class="btn btn-default"
                           href="/system/data_show/delete/{{ table_choice }}/{{ item.store }}"
                           role="button">删除</a>
                    </td>
                {% endif %}
            </tr>
        {% endfor %}
        </tbody>
    </table>



{% endblock %}